import unittest
from selenium import webdriver
import time
from monthor.Page.Page import Page
from ddt import ddt, file_data
from selenium.webdriver.common.by import By
from monthor.Tloos.Tloos import Tloss

@ddt
class Case(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        print("初始化浏览器")

    def tearDown(self) -> None:
        self.driver.quit()
        time.sleep(3)
        print("关闭浏览器")

    @file_data(r'D:\pythonProject\pythonProject\Gwllen\monthor\Data\login.yaml')
    def test_login_01(self, name, pwd):
        """测试登录功能"""
        print(f"执行登录测试，用户名: {name}, 密码: {pwd}")
        po = Page(self.driver)
        po.login_go(name, pwd)
        # 添加断言验证登录是否成功
        time.sleep(5)
        dy = self.driver.find_element(By.XPATH,
                                      "/html/body/div[1]/div/section/section/main/div[1]/form/div[1]/label").text
        print(dy)
        self.assertEqual(dy, "客户姓名")
        print("断言成功")



if __name__ == '__main__':
    unittest.main()
